home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Shaders / RCShaders / RCGouge.sl < prev    next >
Encoding:
Text File  |  1995-03-22  |  692 b   |  24 lines

  1.  
  2. /*
  3.  * gouge(): Use a texture map to displace a surface.
  4.  */
  5. displacement
  6. RCGouge(
  7.     float    Km    = 0.03,
  8.         spin    = 0.0;        /* each pin gets its texture spun */
  9.     string    texturename = "")
  10. {
  11.     float    y = ycomp(transform("object",P));                        /* convert to object space     */
  12.  
  13.    /* Use the same texture map that the surface shader uses. Spin it a different
  14.     *  amount for each pin so that similarity is not detected.  The texture 
  15.     *  determines the size of the gouge. Multiply by the Km factor, then 
  16.     *  displace the surface point inwards by that amount. 
  17.     */
  18.  
  19.    if( texturename != "") 
  20.    {  P += (-Km * texture(texturename,s+spin,y/15.0)) * normalize(N);
  21.       N = calculatenormal(P);
  22.    }
  23. }
  24.